package com.qishon.pc.domain.Application;

import com.qishon.pc.domain.service.PreUploadService;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

/**
 * Created by yuquan.hu on 2016/12/23.
 */
@Component
public class PreUploadManager {

    @Autowired
    private PreUploadService preUploadService;
    public String PreMessage(@RequestParam(value = "filename", required = false) String filename, @RequestParam(value = "file", required = false) MultipartFile file, @RequestParam(value = "file1", required = false) MultipartFile file1, @RequestParam(value = "file2", required = false) MultipartFile file2) throws Exception {

        return preUploadService.Message(filename, file, file1, file2);
    }

    public String PresaveFileToServer(@RequestParam(value = "filename", required = false) String filename, @RequestParam(value = "file", required = false) MultipartFile file, @RequestParam(value = "file1", required = false) MultipartFile file1, @RequestParam(value = "file2", required = false) MultipartFile file2) throws Exception {

        return preUploadService.saveFileToServer(filename, file, file1, file2);
    }

    public void PregetChunkedFileSize(HttpServletRequest request, HttpServletResponse response) throws Exception {

        preUploadService.getChunkedFileSize(request,response);
    }

    public void PreappendUpload2Server(HttpServletRequest request,HttpServletResponse response) throws Exception {

        preUploadService.appendUpload2Server(request,response);
    }
}
